<!DOCTYPE html>
<html lang="zh-CN"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>会员编号充值</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
</head>
<style>
    .layui-input, .layui-textarea {
         display: inline;
         width: 80%;
         padding-left: 10px;
    }
    .unit{
        margin-left: 8px;
    }
    .layui-btn {
        display: inline-block;
        height: 38px;
        line-height: 38px;
        padding: 0 18px;
        background-color: #009688;
        color: #fff;
        white-space: nowrap;
        text-align: center;
        font-size: 14px;
        border: none;
        border-radius: 2px;
        cursor: pointer;
       margin-left: 100px;
        /*margin-top: 10px;*/
        margin-bottom: 10px;
    }
    .imgs-group{
        float: left;
        width: 100px;
        margin-right: 5px;
    }
    .imggroup{
        border: 1px solid #E0E0E0;
    }
</style>
<body>

<div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">规格ID</label>
        <div class="layui-input-inline">
            <input type="text" id="guigeId" name="guigeId" placeholder="规格ID" autocomplete="off" readonly="readonly"  class="layui-input" th:if="${guigePrice!=null}" th:value="${guigePrice.guigeId}" >
            <input type="hidden" id="priceId" name="priceId"  readonly="readonly"  class="layui-input" th:if="${guigePrice!=null}" th:value="${guigePrice.priceId}" >
            <input type="hidden" id="productId" name="productId"  readonly="readonly"  class="layui-input" th:if="${guigePrice!=null}" th:value="${guigePrice.productId}" >
            <!--<label id="noshow" style="color:red;" class="layui-form-mid"></label>-->
        </div>

    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">规格名称</label>
        <div class="layui-input-inline">
            <input type="text" id="guigeName" name="guigeName" th:if="${guigePrice!=null}" th:value="${guigePrice.guigeName}"  placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">规格图片</label>
        <div class="layui-upload-list">
            <img class="layui-upload-img" id="demo1" th:if="${guigePrice!=null}" th:src="@{${guigePrice.imgurl}}" th:width="80" th:height="80">
            <p id="demoText"></p>
        </div>
    </div>
    <div class="layui-upload">
        <button type="button" class="layui-btn" id="test1">上传规格图</button>
    </div>

    <div class="layui-form-item ">
        <label class="layui-form-label">规格图组</label>

            <div class="layui-upload-list" id="demo2"></div>

        <div class=" imgs-group" th:each="imgs:${imgarr}">
            <img class="imggroup imgs-group" id="imggroup" th:if="${imgs!=null}" th:src="@{${imgs}}" th:width="80" th:height="80">
        </div>
    </div>
    <div class="layui-upload">
        <button type="button" class="layui-btn" id="test2">上传规格图组</button>

    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">重量</label>
        <div class="layui-input-inline">
            <input type="text" id="proWeight" name="proWeight" th:if="${guigePrice!=null}" th:value="${guigePrice.proWeight}" placeholder="0.00" autocomplete="off" class="layui-input"><span class="unit">kg</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">大小</label>
        <div class="layui-input-inline">
            <input type="text" id="proSize" name="proSize" th:if="${guigePrice!=null}" th:value="${guigePrice.proSize}"  placeholder="尺寸" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">体积</label>
        <div class="layui-input-inline">
            <input type="text" id="proTiji" name="proTiji" th:if="${guigePrice!=null}" th:value="${guigePrice.proTiji}" placeholder="0.00" autocomplete="off" class="layui-input"><span class="unit">cm3</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">颜色</label>
        <div class="layui-input-inline">
            <input type="text" id="proColor" name="proColor" th:if="${guigePrice!=null}" th:value="${guigePrice.proColor}" placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">容积</label>
        <div class="layui-input-inline">
            <input type="text" id="proVolume" name="proVolume" th:if="${guigePrice!=null}" th:value="${guigePrice.proVolume}" placeholder="0.00" autocomplete="off" class="layui-input"><span class="unit">ml</span>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">长</label>
        <div class="layui-input-inline">
            <input type="text" id="proLength" name="proLength" th:if="${guigePrice!=null}" th:value="${guigePrice.proLength}" placeholder="0.00" autocomplete="off" class="layui-input"><span class="unit">mm</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">宽</label>
        <div class="layui-input-inline">
            <input type="text" id="proWidth" name="proWidth" th:if="${guigePrice!=null}" th:value="${guigePrice.proWidth}" placeholder="0.00" autocomplete="off" class="layui-input"><span class="unit">mm</span>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">高</label>
        <div class="layui-input-inline">
            <input type="text" id="proHeight" name="proHeight" th:if="${guigePrice!=null}" th:value="${guigePrice.proHeight}" placeholder="0.00" autocomplete="off" class="layui-input"><span class="unit">mm</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">购买标志</label>
        <div class="layui-input-inline">
            <input type="text" id="buySign" name="buySign" th:if="${guigePrice!=null}" th:value="${guigePrice.buySign}" placeholder="0.00" autocomplete="off" class="layui-input"><span class="unit"></span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">提成标志</label>
        <div class="layui-input-inline">
            <input type="text" id="commissionSign" name="buySign" th:if="${guigePrice!=null}" th:value="${guigePrice.commissionSign}" placeholder="0.00" autocomplete="off" class="layui-input"><span class="unit"></span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">个人限购数量</label>
        <div class="layui-input-inline">
            <input type="text" id="buyCount" name="buyCount" th:if="${guigePrice!=null}" th:value="${guigePrice.buyCount}" placeholder="0.00" autocomplete="off" class="layui-input"><span class="unit"></span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品限购总数量</label>
        <div class="layui-input-inline">
            <input type="text" id="buyCountTotal" name="buyCountTotal" th:if="${guigePrice!=null}" th:value="${guigePrice.buyCountTotal}" placeholder="0.00" autocomplete="off" class="layui-input"><span class="unit"></span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商城价</label>
        <div class="layui-input-inline">
            <input type="text" id="proPrice" name="proPrice" th:if="${guigePrice!=null}" th:value="${guigePrice.proPrice}" placeholder="0.00" autocomplete="off" class="layui-input"><span class="unit">元</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品成本</label>
        <div class="layui-input-inline">
            <input type="text" id="productCost" name="productCost" th:if="${guigePrice!=null}" th:value="${guigePrice.productCost}" placeholder="0.00" autocomplete="off" class="layui-input"><span class="unit">元</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">运营成本</label>
        <div class="layui-input-inline">
            <input type="text" id="opratorCost" name="opratorCost" th:if="${guigePrice!=null}" th:value="${guigePrice.opratorCost}" placeholder="0.00" autocomplete="off" class="layui-input"><span class="unit">元</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">兑换券</label>
        <div class="layui-input-inline">
            <input type="text" id="coupon" name="coupon" th:if="${guigePrice!=null}" th:value="${guigePrice.coupon}" placeholder="0" autocomplete="off" class="layui-input"><span class="unit">元</span>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">返积分</label>
        <div class="layui-input-inline">
            <input type="text" id="huiyuan" name="huiyuan" th:if="${guigePrice!=null}" th:value="${guigePrice.huiyuan}"  placeholder="0" autocomplete="off" class="layui-input"><span class="unit">元</span>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">店主折扣券</label>
        <div class="layui-input-inline">
            <input type="text" id="dianzhu" name="dianzhu" th:if="${guigePrice!=null}" th:value="${guigePrice.dianzhu}" placeholder="0" autocomplete="off" class="layui-input"><span class="unit">元</span>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">优质店主折扣券</label>
        <div class="layui-input-inline">
            <input type="text" id="yzDianzhu" name="yzDianzhu" th:if="${guigePrice!=null}" th:value="${guigePrice.yzDianzhu}" placeholder="0" autocomplete="off" class="layui-input"><span class="unit">元</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">返代金券</label>
        <div class="layui-input-inline">
            <input type="text" id="visitor" name="visitor" th:if="${guigePrice!=null}" th:value="${guigePrice.visitor}" placeholder="0" autocomplete="off" class="layui-input"><span class="unit">元</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">返购物券</label>
        <div class="layui-input-inline">
            <input type="text" id="otherRank" name="otherRank" th:if="${guigePrice!=null}" th:value="${guigePrice.otherRank}" placeholder="0" autocomplete="off" class="layui-input"><span class="unit">元</span>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-user-front-submit" id="LAY-user-back-submit" value="确认">
    </div>
</div>

<script th:src="@{/layui/layui.js}"></script>
<script th:src="@{/layui/jquery.min.js}"></script>
<script>
    var guigeId=$('#guigeId').val();
    layui.use('upload', function(){
        var $ = layui.jquery
            ,upload = layui.upload;
        //上传规格图
        var uploadInst = upload.render({
            elem: '#test1'
            ,url: '/updateGuiGeImgs'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){

                if(res.msg=='1'){//上传成功
                    layer.msg('上传成功！');
                }else{
                    layer.msg('上传失败！');
                }
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });

        //上传规格图组
        upload.render({
            elem: '#test2'
            ,url: '/updateGuiGeGroupImgs'
            ,multiple: true
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('.imgs-group').remove();
                    $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img" th:width="80" th:height="80">')
                });
            }
            ,done: function(res){
                if(res.msg=='1'){
                    layer.msg("上传成功！");
                }else{
                    layer.msg("上传失败！");
                }
                //上传完毕
            }
        });

    });

    //删除显示的图组
    delGroupImg();
    function delGroupImg(){
        $('.imgs-group').on('click',function () {
            $('.imgs-group').remove();
        })
    }


</script>

</body>
</html>